package com.example.qgorderprovider.mapper;

import com.sun.istack.internal.Interned;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    //添加订单
    @Insert("insert into qg_order values(#{id},#{userId},#{stockId},#{orderNo},#{goodsId},#{num},#{amount},#{status},null,now(),now())")
    public int AddOrder(Map map);

    //显示该用户的所有订单
    @Select("select o.*,g.goodsImg from qg_order o join goods g on o.goodsId=g.id where o.userId=#{userId}")
    public List<Map> getOrdersByUid(int userId);

    @Select("select * from qg_order where id=#{id}")
    public Map getById(String id);

    //修改订单状态
    @Update("update qg_order set status=#{version} where id=#{out_trade_no}")
    public int updateStatus(Map map);
}
